<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="z" uri="zz" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <%@include file="/views/common/common.jsp" %>
    <script type="text/javascript">
        function sendNotice() {
            var url = $("#receiveUrl_id").val();
            var type = $("#notice_type_id").val();
            var title = $("#title_id").val();

            var ue = UE.getEditor('content');
            var html = ue.getContent();

            console.log(url + ":" + type + ":" + title + ":" + html)
            console.log('customerNoticeSend?url=' + url + '&type=' + type + '&title=' + title + '&content=' + html)

            if (isNotNull(url)) {
                if (isNotNull(type)) {
                    if (isNotNull(title)) {
                        $.messager.confirm('信息提示', '您确定要给这些用户发送通知吗？', function (r) {
                            if (r) {
                                $.ajax({
                                    type: "get",
                                    url: "customerNoticeSend",
                                    data: {url: url, type: type, title: title, content: html},
                                    success: function (data) {
                                        if (data.code == 'SUCCESS') {
                                            parent.alertMessager('发放成功');
                                            location.reload();
                                        } else {
                                            parent.alertErrorMessager('' + data.msg);
                                        }
                                    },
                                    error: function (data) {
                                        parent.alertErrorMessager('ajax错误：' + JSON.stringify(data));
                                    }
                                });
                            }
                        });

                    } else {
                        parent.alertErrorMessager('标题不能为空');
                    }

                } else {
                    parent.alertErrorMessager('类型不能为空');
                }
            } else {
                parent.alertErrorMessager('客户不能为空');
            }
        }

    </script>
</head>
<body class="easyui-layout">
<div data-options="region:'north'" class="border-top-0 border-right-0 border-left-0"
     style="height:38px;overflow:hidden">
    <div id="ButtonHR" class="btn-group" role="group">
        <c:if test="${is_mobile=='1'}">
            <button id="return_button" type="button" class="btn btn-light"
                    onclick="window.location.href='user_center_mobile';"><i class="fa fa-hand-o-left"></i> 返回
            </button>
        </c:if>
        <button id="sendButton" type="button" class="btn btn-light" onclick="sendNotice();"><i
                class="fa fa-floppy-o"></i> 发送
        </button>
        <button id="sendButton" type="button" class="btn btn-light"
                onclick="window.location.href = 'http://files.jlsmerro.com/files/20221103152051577228/notice.xls'"><i
                class="fa fa-floppy-o"></i> 下载接收人模版
        </button>
    </div>

</div>
<div data-options="region:'center',border:false" style="margin-top: 10px">
    <z:column column_size="4" column_type="3" column_id="receiveUrl" column_name="接收人" column_help=""/>
    <z:column column_size="4" column_type="7" column_id="notice_type" column_name="通知类型" p_code_id="notice_type"/>
    <z:column column_size="4" column_type="0" column_id="title" column_name="标题" column_help=""/>
    <div class="input-group-prepend" style="margin-left: 15px">
        <div class="input-group-text ">内容：</div>
    </div>
    <textarea id="content" name="info" style="height: 200px;margin-left: 20px;margin-right: 20px"></textarea>
    <script type="text/javascript">InitHTMLColumn('content');</script>
</div>
</div>

<%@include file="/views/common/body.jsp" %>
</body>
</html>